package com.foreknow.homework0928;

public class TestStudent {
    public Student[] Array;
    public int count = 0;

    public TestStudent() {
        Array = new Student[5];
    }

    public void addStudent(Student student) {
        if (student != null) {
            Array[count] = student;
            count++;
        }
    }

    public void getScore() {
        for (int i = 0; i < count; i++) {
            for (int j = 0; j < count; j++) {
                if (Array[i].getScore() >= Array[j].getScore()) {
                    Student student = new Student();
                    student = Array[i];
                    Array[i] = Array[j];
                    Array[j] = student;
                }
            }
        }
        for (int i = 0; i < count; i++) {
            System.out.println(Array[i].getName() + "  " + Array[i].getSno() + "  " + Array[i].getScore());
        }
    }

    public static void main(String[] args) {
        TestStudent ts = new TestStudent();
        Student s1 = new Student("tom", 101, 50);
        Student s2 = new Student("jack", 102, 70);
        Student s3 = new Student("mike", 103, 30);
        Student s4 = new Student("rose", 104, 80);
        ts.addStudent(s1);
        ts.addStudent(s2);
        ts.addStudent(s3);
        ts.addStudent(s4);
        ts.getScore();
    }
}
